package com.deyou.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.deyou.R;
import com.deyou.base.BaseActivity;
import com.deyou.event.DebookRulesEvent;
import com.deyou.util.AndroidUtils;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class DeBookRulesActivity extends BaseActivity {

    @BindView(R.id.tv_mid_title)
    TextView tvMidTitle;
    @BindView(R.id.iv_choosed_normal_debook)
    ImageView ivChoosedNormalDebook;
    @BindView(R.id.iv_choosed_custom_debook)
    ImageView ivChoosedCustomDebook;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_debook_rules);
        EventBus.getDefault().register(this);
        ButterKnife.bind(this);
        tvMidTitle.setText("退订政策");
    }

    @Override
    protected boolean translucentStatusBar() {
        return super.translucentStatusBar();
    }

    @OnClick({R.id.iv_left_back, R.id.normal_debook_layout, R.id.custom_debook_layout})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_left_back:
                finish();
                break;
            case R.id.normal_debook_layout:
                ivChoosedNormalDebook.setVisibility(View.VISIBLE);
                ivChoosedCustomDebook.setVisibility(View.INVISIBLE);
                AndroidUtils.startNextActivity(DeBookRulesActivity.this, NormalDebookRulesActivity.class, null, false);
                break;
            case R.id.custom_debook_layout:
                ivChoosedNormalDebook.setVisibility(View.INVISIBLE);
                ivChoosedCustomDebook.setVisibility(View.VISIBLE);
                AndroidUtils.startNextActivity(DeBookRulesActivity.this, CustomDebookRulesActivity.class, null, false);
                break;
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe
    public void onEventMainThread(DebookRulesEvent event){
        if (event.needFinish)
            finish();
    }
}
